#ifndef CONVERTER_H
#define CONVERTER_H

#include <QtCore>

class Converter: public QProcess
{
	Q_OBJECT

signals:
	void stderrLineOutput(const QString &);
	void stdoutLineOutput(const QString &);
	
public:
	Converter(const QString &, QObject *parent = NULL);
	virtual ~Converter();
	
	void setConverter(const QString &s)	{ _converter = s; }
	const QString & converter() const	{ return _converter; }
	void setArguments(const QString &);
	
	virtual void convert(const QString &args = QString());
	virtual void abort();
	
	bool isRunning() const;
	
	int timeElapsed() const;
	
protected:

private slots:
	void poll();	//< polling process output
	void cleanup(int, QProcess::ExitStatus);	//< cleanup after process finished

private:
	QString _converter;
	QString _args;
	
	QString _stderr, _stdout;
	
	QTime _elapsedTime;
	QTimer _watchOutputTimer;
};

#endif	// CONVERTER_H
